package com.konne.nightmare.FastPublicOpinion.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.SizeUtils;
import com.konne.nightmare.FastPublicOpinion.R;

/**
 * Create by ws.
 * on Data:2022/1/25  Time:上午 11:12.
 * description: 成员管理功能弹窗 .
 */
public class MemberManagerFunDialog extends Dialog implements View.OnClickListener{
    private View cl_fun_appoint;
    private View cl_fun_sys;
    private View cl_fun_free;
    private MemberManagerFunListener memberManagerFunListener;
    public MemberManagerFunDialog(@NonNull Context context) {
        super(context);
    }

    public MemberManagerFunDialog setMemberManagerFunListener(MemberManagerFunListener memberManagerFunListener) {
        this.memberManagerFunListener = memberManagerFunListener;
        return this;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_member_manager_fun);
        Window dialogWindow = getWindow();
        dialogWindow.setBackgroundDrawableResource(android.R.color.transparent);
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.width = SizeUtils.dp2px(210);
        lp.height = SizeUtils.dp2px(210);
        lp.dimAmount = 0.3f;
        dialogWindow.setAttributes(lp);
        dialogWindow.getDecorView().setPadding(0, 0, SizeUtils.dp2px(10), SizeUtils.dp2px(10)); //设置边距
        dialogWindow.setGravity(Gravity.BOTTOM|Gravity.RIGHT);
        cl_fun_appoint=findViewById(R.id.cl_fun_appoint);
        cl_fun_sys=findViewById(R.id.cl_fun_sys);
        cl_fun_free=findViewById(R.id.cl_fun_free);
        findViewById(R.id.iv_dismiss).setOnClickListener(this::onClick);
        cl_fun_appoint.setOnClickListener(this);
        cl_fun_sys.setOnClickListener(this);
        cl_fun_free.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.cl_fun_appoint:
                if(memberManagerFunListener!=null){
                    memberManagerFunListener.fun(0);
                }
                break;
            case R.id.cl_fun_sys:
                if(memberManagerFunListener!=null){
                    memberManagerFunListener.fun(1);
                }
                break;
            case R.id.cl_fun_free:
                if(memberManagerFunListener!=null){
                    memberManagerFunListener.fun(2);
                }
                break;
        }
        dismiss();
    }
    public interface MemberManagerFunListener{
        void fun(int type);
    }
}
